
package net.seehealth.healthpad.ui;

import java.util.ArrayList;
import java.util.List;

import net.seehealth.healthpad.Constants.Main;
import net.seehealth.healthpad.R;
import net.seehealth.healthpad.application.adapter.MainListAdapter;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ListView;
import android.widget.TextView;

/**
 * 
 * @className MainListActivity
 * @author wuhongjie
 * @description 公告列表页面  健康宣教列表界面
 * @date 2012-4-16 下午11:43:15
 */
public class MainListActivity extends BaseActivity {
	
	/** 返回按钮 **/
	private ImageButton mBackBtn;
	
	/** 标题 **/
	private TextView mTitleLabel;
	
	/** 列表控件 **/
	private ListView mListView;
	
	/** 列表适配器 **/
	private MainListAdapter mAdapter;
	
	/** 列表内容 **/
	private List<List<String>> mContent;
	
	/** 模块类型 **/
	private int type;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		// 初始化数据
		initData();

		// 初始化视图
		initView();

	}

	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	protected void onPause() {
		super.onPause();
		
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {

		return super.onKeyDown(keyCode, event);
	}

	/**
	 * 初始化界面
	 */
	private void initView(){
		setContentView(R.layout.main_list);
		mTitleLabel = (TextView) findViewById(R.id.tv_common_title);
		
		mBackBtn = (ImageButton)findViewById(R.id.ib_common_back); 
		mBackBtn.setOnClickListener(clickListener);
		
		mListView = (ListView) findViewById(R.id.lv_main_list);
		mListView.setAdapter(mAdapter);

		type = getIntent().getIntExtra(Main.TYPE, Main.ANNOUNCE);
		if(type == Main.ANNOUNCE) {
			mTitleLabel.setText("系统公告");
		} else if(type == Main.MESSAGE) {
			mTitleLabel.setText("健康宣教");
		}
	}

	/**
	 * 初始化数据
	 */
	private void initData(){

		mContent = new ArrayList<List<String>>();
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());
		mContent.add(new ArrayList<String>());

		mAdapter = new MainListAdapter(mContext, type);
		mAdapter.setData(mContent);
	}

	/**
	 * 点击事件
	 */
	View.OnClickListener clickListener = new View.OnClickListener() {

		@Override
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.ib_common_back:		//返回键
				finish();
				break;
			}
		}
	};
	
}
